580E - Kefa and Watch - CodeForces Solution


data structures hashing strings *2500

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#include<cmath>
#define ll long long
#define For(i,a,b) for(ll i=a;i<=b;i++)
#define Rof(i,a,b) for(ll i=a;i>=b;i--)
#define N 100010
#define pb push_back
#define ls x<<1
#define rs x<<1|1
#define lson ls,l,mid
#define rson rs,mid+1,r
#define SP fixed<<setprecision(12)
#define mk make_pair
#define pque priority_queue

using namespace std;
char s[N];
int n,m,q,op,l,r,k;

ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


int main()
{
    n=read(),m=read(),q=read();
    cin>>(s+1);
    For(i,1,m+q){
    	op=read(),l=read(),r=read(),k=read();
    	if(op==1) memset(s+l,k+'0',r-l+1);
    	else{
    		if(memcmp(s+l,s+l+k,r-l-k+1)) printf("NO\n");
    		else printf("YES\n");
		}
	}
    return 0;
}


Comments

Submit
0 Comments
More Questions

387A - George and Sleep
53A - Autocomplete
1729G - Cut Substrings
805B - 3-palindrome
805C - Find Amir
676C - Vasya and String
1042B - Vitamins
1729F - Kirei and the Linear Function
25D - Roads not only in Berland
1694A - Creep
659F - Polycarp and Hay
1040A - Palindrome Dance
372A - Counting Kangaroos is Fun
1396B - Stoned Game
16A - Flag
1056A - Determine Line
670B - Game of Robots
1418C - Mortal Kombat Tower
1382B - Sequential Nim
1272C - Yet Another Broken Keyboard
808A - Lucky Year
1245A - Good ol' Numbers Coloring
58B - Coins
1041C - Coffee Break
507A - Amr and Music
1041D - Glider
1486A - Shifting Stacks
1389B - Array Walk
71B - Progress Bar
701A - Cards